<?php
/**
 * Authorization request object
 * 
 * @package stanza.auth
 */
class Zend_Jabber_Stanza_Request_Auth extends Zend_Jabber_Stanza_Request_Abstract {
    /**
     * Create new authorization request object
     * 
     * @param Zend_Jabber_User $user User
     * @param string $password Password
     * @param string $mechanism Authorization mechanism
     */
    public function __construct(Zend_Jabber_User $user, $password, $mechanism=Zend_Jabber_Connection::MECHANISM_PLAIN) {
        parent::__construct();

        $auth = $this->dom->createElement('auth', base64_encode('' . chr(0) . $user->getUsername() . chr(0) . $password));
        $auth->setAttribute('mechanism', $mechanism);
        $auth->setAttribute('xmlns', Zend_Jabber_Connection::NS_SASL);
        
        $this->dom->appendChild($auth);
    }
    
    /**
     * Get request class (not the actual class of this object)
     */
    public function getClass() {
        return $this->getType();
    }
}
?>